<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>hybridMPIC: injector.h Source File</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../logo.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">hybridMPIC
   </div>
   <div id="projectbrief">A fully relativisitic 2d Particle-In-Cell(PIC) code, with explicit solver, MPI&amp;OpenMP support</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.9.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="../../index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="../../pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="../../annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="../../files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="../../search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="../../search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="../../files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">injector.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef __INJECT</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define __INJECT</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#include&lt;vector&gt;</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &quot;type.h&quot;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &quot;simbox.h&quot;</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &quot;particles.h&quot;</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &quot;events.h&quot;</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &quot;physicalconstants.h&quot;</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;</div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;</div>
<div class="line"><a name="l00012"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html">   12</a></span>&#160;<span class="keyword">class </span><a class="code" href="../../de/d11/class____Injector.html">__Injector</a>{</div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;    <span class="keyword">public</span>:</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;        <span class="keywordtype">int</span> id;</div>
<div class="line"><a name="l00016"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#a4b73407b88f8100467ff96223daf0c16">   16</a></span>&#160;        <span class="keywordtype">int</span> <a class="code" href="../../de/d11/class____Injector.html#a4b73407b88f8100467ff96223daf0c16">species</a>;</div>
<div class="line"><a name="l00018"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#af77a69bb48ddf567a7bf0bee02cd9ffb">   18</a></span>&#160;        <a class="code" href="../../d6/d9c/class____Vect2.html">__Vect2&lt;long&gt;</a> <a class="code" href="../../de/d11/class____Injector.html#af77a69bb48ddf567a7bf0bee02cd9ffb">position</a>;</div>
<div class="line"><a name="l00020"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#a1e2e93fb02efca4f2cb4a0d5afb56c8a">   20</a></span>&#160;        <a class="code" href="../../d6/d9c/class____Vect2.html">__Vect2&lt;double&gt;</a> <a class="code" href="../../de/d11/class____Injector.html#a1e2e93fb02efca4f2cb4a0d5afb56c8a">gps</a>;</div>
<div class="line"><a name="l00022"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#aaf0d94bdf7f6bf59a56f9ad7335ee591">   22</a></span>&#160;        <a class="code" href="../../da/d1a/class____Vect3.html">__Vect3&lt;double&gt;</a> <a class="code" href="../../de/d11/class____Injector.html#aaf0d94bdf7f6bf59a56f9ad7335ee591">velocity</a>;</div>
<div class="line"><a name="l00024"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#a904426b2cee84aa9f4fa90f8af6d443d">   24</a></span>&#160;        <span class="keyword">static</span> <span class="keywordtype">long</span>&amp; <a class="code" href="../../de/d11/class____Injector.html#a904426b2cee84aa9f4fa90f8af6d443d">pid</a>;</div>
<div class="line"><a name="l00026"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#a50f2657e4e2d8fe60619f8c7b9f23a8c">   26</a></span>&#160;        <span class="keywordtype">double</span> <a class="code" href="../../de/d11/class____Injector.html#a50f2657e4e2d8fe60619f8c7b9f23a8c">length</a>;</div>
<div class="line"><a name="l00028"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#aa4848c52c3ab0b96e3ab6ec78f1956e4">   28</a></span>&#160;        <span class="keywordtype">int</span> <a class="code" href="../../de/d11/class____Injector.html#aa4848c52c3ab0b96e3ab6ec78f1956e4">repetion</a>;</div>
<div class="line"><a name="l00030"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#a3463b30b920b35418ded0984fe8ae387">   30</a></span>&#160;        <span class="keywordtype">double</span> <a class="code" href="../../de/d11/class____Injector.html#a3463b30b920b35418ded0984fe8ae387">flux</a>;</div>
<div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#a4ecfae6ba4e8efc87b3ff5d3f20d3836">   32</a></span>&#160;        <span class="keywordtype">double</span> <a class="code" href="../../de/d11/class____Injector.html#a4ecfae6ba4e8efc87b3ff5d3f20d3836">dx</a>, dy;</div>
<div class="line"><a name="l00034"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#a92a9bdb86b5d437c638e06508d8c9fa6">   34</a></span>&#160;        <span class="keywordtype">long</span> <a class="code" href="../../de/d11/class____Injector.html#a92a9bdb86b5d437c638e06508d8c9fa6">diameter</a>;</div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#a766d44b1386fd4f010f0bd43f36f3ad0">   36</a></span>&#160;        <span class="keywordtype">double</span> <a class="code" href="../../de/d11/class____Injector.html#a766d44b1386fd4f010f0bd43f36f3ad0">energy</a>;</div>
<div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#a4c049ee41a130898e724da94f449ee2c">   38</a></span>&#160;        <span class="keywordtype">double</span> <a class="code" href="../../de/d11/class____Injector.html#a4c049ee41a130898e724da94f449ee2c">charge</a>;</div>
<div class="line"><a name="l00040"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#afdfbc1a91bff64ae7d72ae5cf5d66523">   40</a></span>&#160;        <span class="keywordtype">double</span> <a class="code" href="../../de/d11/class____Injector.html#afdfbc1a91bff64ae7d72ae5cf5d66523">mass</a>;</div>
<div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#a648d24d44961e7a00296d743b155574c">   42</a></span>&#160;        <span class="keywordtype">long</span> <a class="code" href="../../de/d11/class____Injector.html#a648d24d44961e7a00296d743b155574c">total</a>;</div>
<div class="line"><a name="l00044"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#ab60f580734f6773a8c0a1c89772b4fd4">   44</a></span>&#160;        <span class="keywordtype">double</span> <a class="code" href="../../de/d11/class____Injector.html#ab60f580734f6773a8c0a1c89772b4fd4">lorentz_gamma</a>;</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;        <a class="code" href="../../de/d11/class____Injector.html">__Injector</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <span class="keywordtype">int</span> species, <span class="keyword">const</span> <span class="keywordtype">double</span>&amp; charge, <span class="keyword">const</span> <span class="keywordtype">double</span>&amp; mass, <a class="code" href="../../d6/d9c/class____Vect2.html">__Vect2&lt;long&gt;</a> position, \</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;                <a class="code" href="../../da/d1a/class____Vect3.html">__Vect3&lt;double&gt;</a>&amp; velocity, <span class="keyword">const</span> <span class="keywordtype">long</span>&amp; total, \</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;                <span class="keyword">const</span> <span class="keywordtype">double</span> length, <span class="keyword">const</span> <span class="keywordtype">double</span> flux, <span class="keyword">const</span> <span class="keywordtype">double</span>&amp; dx, <span class="keyword">const</span> \</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;                <span class="keywordtype">double</span>&amp; dy):id(id), species(species), charge(charge), mass(mass)\</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;        , velocity(velocity), position(position), total(total), length(length), \</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;                            flux(flux), \</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;                            dx(dx), dy(dy){ </div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;            diameter = length / 2.0 / <a class="code" href="../../de/d11/class____Injector.html#a4ecfae6ba4e8efc87b3ff5d3f20d3836">dx</a>; </div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;            lorentz_gamma = 1.0 / sqrt(1.0 - velocity * velocity / c_light_speed / c_light_speed);</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;            energy = lorentz_gamma * mc2;</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;        }</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;        ~<a class="code" href="../../de/d11/class____Injector.html">__Injector</a>(){}</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;        <span class="keywordtype">void</span> <a class="code" href="../../de/d11/class____Injector.html#a921bbb4ec1562cfd7ab4e8ac76b619b8">trigger</a>(<a class="code" href="../../d9/d37/class____Simbox.html">__Simbox</a>&amp; mybox);</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;        <span class="keywordtype">void</span> destroy();</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;};</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;</div>
<div class="line"><a name="l00065"></a><span class="lineno"><a class="line" href="../../de/d11/class____Injector.html#a921bbb4ec1562cfd7ab4e8ac76b619b8">   65</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="../../de/d11/class____Injector.html#a921bbb4ec1562cfd7ab4e8ac76b619b8">__Injector::trigger</a>(<a class="code" href="../../d9/d37/class____Simbox.html">__Simbox</a>&amp; mybox)</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;{</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    <span class="keywordflow">if</span>(<a class="code" href="../../de/d11/class____Injector.html#a648d24d44961e7a00296d743b155574c">total</a> &lt;= 0)</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;    {</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;        <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;    }</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    <span class="keywordtype">int</span> ptcls_num  = 100;<span class="comment">//mybox.delta_t * flux * length / weight;</span></div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    <span class="comment">//cout&lt;&lt;&quot;pnu &quot;&lt;&lt;mybox.delta_t&lt;&lt;&quot; flu &quot;&lt;&lt;flux&lt;&lt;&quot; len &quot;&lt;&lt;length&lt;&lt;&quot; wt &quot;&lt;&lt;weight&lt;&lt;endl;</span></div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;    <span class="keywordtype">double</span> len_x = <a class="code" href="../../de/d11/class____Injector.html#aaf0d94bdf7f6bf59a56f9ad7335ee591">velocity</a>.member[0] * mybox.<a class="code" href="../../d9/d37/class____Simbox.html#a401c24180edf0702b647430fdd3fe18d">delta_t</a>;</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;    <span class="keywordtype">double</span> ybx = <a class="code" href="../../de/d11/class____Injector.html#a50f2657e4e2d8fe60619f8c7b9f23a8c">length</a> / len_x;</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;    <span class="keywordtype">int</span> nx = sqrt(ptcls_num / ybx);</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;    <span class="keywordtype">int</span> ny = nx * ybx;</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;    <span class="keywordflow">if</span>(nx &lt;= 1)</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;    {</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;        nx = 1;</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;        ny = ptcls_num / nx;</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;    }</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;    <span class="comment">//cout&lt;&lt;&quot;ybx, nx, ny &quot;&lt;&lt;ybx&lt;&lt;&quot;\t&quot;&lt;&lt;nx&lt;&lt;&quot;\t&quot;&lt;&lt;ny&lt;&lt;endl;</span></div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    <span class="keywordtype">double</span> ddx = len_x / nx, ddy = <a class="code" href="../../de/d11/class____Injector.html#a50f2657e4e2d8fe60619f8c7b9f23a8c">length</a> / ny;</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;    <span class="keywordtype">long</span> weight = <a class="code" href="../../de/d11/class____Injector.html#a3463b30b920b35418ded0984fe8ae387">flux</a> * <a class="code" href="../../de/d11/class____Injector.html#a50f2657e4e2d8fe60619f8c7b9f23a8c">length</a> * len_x / ptcls_num;</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;    <a class="code" href="../../d6/d9c/class____Vect2.html">__Vect2&lt;double&gt;</a> pos(<a class="code" href="../../de/d11/class____Injector.html#af77a69bb48ddf567a7bf0bee02cd9ffb">position</a>.member[0], <a class="code" href="../../de/d11/class____Injector.html#af77a69bb48ddf567a7bf0bee02cd9ffb">position</a>.member[1]);</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;    <span class="comment">//cout&lt;&lt;&quot;pos &quot;&lt;&lt;pos&lt;&lt;endl;</span></div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;    <a class="code" href="../../d6/d9c/class____Vect2.html">__Vect2&lt;double&gt;</a> particle_position0 = pos * <a class="code" href="../../de/d11/class____Injector.html#a4ecfae6ba4e8efc87b3ff5d3f20d3836">dx</a>;</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    particle_position0.member[1] -= <a class="code" href="../../de/d11/class____Injector.html#a50f2657e4e2d8fe60619f8c7b9f23a8c">length</a> * 0.5;</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    <span class="keywordtype">int</span> posi, posj;</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;    <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0; i &lt; ptcls_num; i ++)</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;    {</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;        <a class="code" href="../../d6/d9c/class____Vect2.html">__Vect2&lt;double&gt;</a> particle_position = particle_position0; <span class="comment">// + offset * (i * 1.0 / ptcls_num);</span></div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;        particle_position.member[0] += len_x * random_generator();</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;        particle_position.member[1] += <a class="code" href="../../de/d11/class____Injector.html#a50f2657e4e2d8fe60619f8c7b9f23a8c">length</a> * random_generator();</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;        posi = (particle_position.member[0] - mybox.<a class="code" href="../../d9/d37/class____Simbox.html#a6d6a6dbebdbce9237e486e516fef25d9">xymin</a>.member[0]) / dx;</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;        posj = (particle_position.member[1] - mybox.<a class="code" href="../../d9/d37/class____Simbox.html#a6d6a6dbebdbce9237e486e516fef25d9">xymin</a>.member[1]) / dy;</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;        <span class="comment">//cout&lt;&lt;&quot;i, j &quot;&lt;&lt;posi&lt;&lt;&quot;\t&quot;&lt;&lt;posj&lt;&lt;&quot; &quot;&lt;&lt;particle_position&lt;&lt;endl;</span></div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;        <span class="comment">//cout&lt;&lt;&quot;velocity &quot;&lt;&lt;velocity&lt;&lt;endl;</span></div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;        <span class="comment">//cout&lt;&lt;&quot;before creating &quot;&lt;&lt;pid&lt;&lt;endl;</span></div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;        <a class="code" href="../../d9/ddf/class____Ptcls.html">__Ptcls</a> myptcl(particle_position, <a class="code" href="../../de/d11/class____Injector.html#aaf0d94bdf7f6bf59a56f9ad7335ee591">velocity</a>, weight, <a class="code" href="../../de/d11/class____Injector.html#a766d44b1386fd4f010f0bd43f36f3ad0">energy</a>, \</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;                <a class="code" href="../../de/d11/class____Injector.html#a4c049ee41a130898e724da94f449ee2c">charge</a>);</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;        <span class="comment">//cout&lt;&lt;&quot;after creating &quot;&lt;&lt;pid&lt;&lt;&quot;\t total_id &quot;&lt;&lt;myptcl.total_id&lt;&lt;endl;</span></div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;        myptcl.<a class="code" href="../../d9/ddf/class____Ptcls.html#a4c8ff1d2388163601e00c6685af2859a">mass</a> = <a class="code" href="../../de/d11/class____Injector.html#afdfbc1a91bff64ae7d72ae5cf5d66523">mass</a>;</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;        myptcl.<a class="code" href="../../d9/ddf/class____Ptcls.html#a190602549e77f92d18694bfac93774de">species</a> = <a class="code" href="../../de/d11/class____Injector.html#a4b73407b88f8100467ff96223daf0c16">species</a>;</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;        myptcl.lorentz_gamma = <a class="code" href="../../de/d11/class____Injector.html#ab60f580734f6773a8c0a1c89772b4fd4">lorentz_gamma</a>;</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;        <span class="comment">//myptcl.total_id = pid;</span></div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;        <span class="comment">//cout&lt;&lt;&quot; particle id &quot;&lt;&lt;myptcl.id&lt;&lt;endl;</span></div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;        <span class="comment">//getchar();</span></div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;        mybox.<a class="code" href="../../d9/d37/class____Simbox.html#a5bcfefa55f12a83d66d28b8e23fbd0f4">cellgroup</a>.<a class="code" href="../../d3/dac/class____Cellgroup.html#aa2e1725d6a24ff12ccdc236d55682a73">member</a>[posi][posj].push(myptcl);</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;        <a class="code" href="../../de/d11/class____Injector.html#a648d24d44961e7a00296d743b155574c">total</a> --;</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;        <span class="keywordflow">if</span>(<a class="code" href="../../de/d11/class____Injector.html#a648d24d44961e7a00296d743b155574c">total</a> &lt;= 0)</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;        {</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;            <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;        }</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;    }</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    <span class="comment">/***</span></div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;<span class="comment">    for(int i = 0; i &lt; nx; i ++)</span></div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;<span class="comment">    {</span></div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;<span class="comment">        for(int j = 0; j &lt; ny; j ++)</span></div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;<span class="comment">        {</span></div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;<span class="comment">            __Vect2&lt;double&gt; particle_position = particle_position0; // + offset * (i * 1.0 / ptcls_num);</span></div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;<span class="comment">            particle_position.member[0] += i * ddx;</span></div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;<span class="comment">            particle_position.member[1] += j * ddy;</span></div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;<span class="comment">            posi = (particle_position.member[0] - mybox.xymin.member[0]) / dx;</span></div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;<span class="comment">            posj = (particle_position.member[1] - mybox.xymin.member[1]) / dy;</span></div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;<span class="comment">            //cout&lt;&lt;&quot;ek &quot;&lt;&lt;energy&lt;&lt;endl;</span></div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;<span class="comment">            //cout&lt;&lt;&quot;i, j &quot;&lt;&lt;posi&lt;&lt;&quot;\t&quot;&lt;&lt;posj&lt;&lt;&quot; &quot;&lt;&lt;particle_position&lt;&lt;endl;</span></div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;<span class="comment">            //cout&lt;&lt;&quot;velocity &quot;&lt;&lt;velocity&lt;&lt;endl;</span></div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;<span class="comment">            __Ptcls myptcl(pid, particle_position, velocity, weight, energy, \</span></div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;<span class="comment">                    charge);</span></div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;<span class="comment">            myptcl.mass = mass;</span></div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;<span class="comment">            myptcl.species = species;</span></div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;<span class="comment">            mybox.cellgroup.member[posi][posj].push(myptcl);</span></div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;<span class="comment">            pid ++;</span></div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;<span class="comment">        }</span></div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;<span class="comment">    }</span></div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;<span class="comment">    ***/</span></div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;}</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;<span class="comment">/***</span></div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;<span class="comment">void __Injector::destroy()</span></div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;<span class="comment">{</span></div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;<span class="comment">    ~__Injector();</span></div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;<span class="comment">}</span></div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;<span class="comment">***/</span></div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;        </div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="ttc" id="class____Injector_html_a4ecfae6ba4e8efc87b3ff5d3f20d3836"><div class="ttname"><a href="../../de/d11/class____Injector.html#a4ecfae6ba4e8efc87b3ff5d3f20d3836">__Injector::dx</a></div><div class="ttdeci">double dx</div><div class="ttdoc">网格的x,y方向的宽度 </div><div class="ttdef"><b>Definition:</b> injector.h:32</div></div>
<div class="ttc" id="class____Vect2_html"><div class="ttname"><a href="../../d6/d9c/class____Vect2.html">__Vect2&lt; long &gt;</a></div></div>
<div class="ttc" id="class____Ptcls_html"><div class="ttname"><a href="../../d9/ddf/class____Ptcls.html">__Ptcls</a></div><div class="ttdoc">单个粒子类信息，可以是任何种类粒子 </div><div class="ttdef"><b>Definition:</b> particles.h:9</div></div>
<div class="ttc" id="class____Injector_html_afdfbc1a91bff64ae7d72ae5cf5d66523"><div class="ttname"><a href="../../de/d11/class____Injector.html#afdfbc1a91bff64ae7d72ae5cf5d66523">__Injector::mass</a></div><div class="ttdeci">double mass</div><div class="ttdoc">粒子质量 </div><div class="ttdef"><b>Definition:</b> injector.h:40</div></div>
<div class="ttc" id="class____Simbox_html_a6d6a6dbebdbce9237e486e516fef25d9"><div class="ttname"><a href="../../d9/d37/class____Simbox.html#a6d6a6dbebdbce9237e486e516fef25d9">__Simbox::xymin</a></div><div class="ttdeci">__Vect2&lt; double &gt; xymin</div><div class="ttdoc">盒子xy最小值 </div><div class="ttdef"><b>Definition:</b> simbox.h:74</div></div>
<div class="ttc" id="class____Injector_html_ab60f580734f6773a8c0a1c89772b4fd4"><div class="ttname"><a href="../../de/d11/class____Injector.html#ab60f580734f6773a8c0a1c89772b4fd4">__Injector::lorentz_gamma</a></div><div class="ttdeci">double lorentz_gamma</div><div class="ttdoc">粒子的gamma因子 </div><div class="ttdef"><b>Definition:</b> injector.h:44</div></div>
<div class="ttc" id="class____Cellgroup_html_aa2e1725d6a24ff12ccdc236d55682a73"><div class="ttname"><a href="../../d3/dac/class____Cellgroup.html#aa2e1725d6a24ff12ccdc236d55682a73">__Cellgroup::member</a></div><div class="ttdeci">vector&lt; vector&lt; __Cellinfo &gt; &gt; member</div><div class="ttdoc">cellinfo 数据 </div><div class="ttdef"><b>Definition:</b> cellinf.h:631</div></div>
<div class="ttc" id="class____Injector_html_af77a69bb48ddf567a7bf0bee02cd9ffb"><div class="ttname"><a href="../../de/d11/class____Injector.html#af77a69bb48ddf567a7bf0bee02cd9ffb">__Injector::position</a></div><div class="ttdeci">__Vect2&lt; long &gt; position</div><div class="ttdoc">枪的中心位置 </div><div class="ttdef"><b>Definition:</b> injector.h:18</div></div>
<div class="ttc" id="class____Injector_html_a904426b2cee84aa9f4fa90f8af6d443d"><div class="ttname"><a href="../../de/d11/class____Injector.html#a904426b2cee84aa9f4fa90f8af6d443d">__Injector::pid</a></div><div class="ttdeci">static long &amp; pid</div><div class="ttdoc">初始粒子的id </div><div class="ttdef"><b>Definition:</b> injector.h:24</div></div>
<div class="ttc" id="class____Simbox_html_a401c24180edf0702b647430fdd3fe18d"><div class="ttname"><a href="../../d9/d37/class____Simbox.html#a401c24180edf0702b647430fdd3fe18d">__Simbox::delta_t</a></div><div class="ttdeci">double delta_t</div><div class="ttdoc">dt 根据网格宽度和Corant 条件算出 </div><div class="ttdef"><b>Definition:</b> simbox.h:88</div></div>
<div class="ttc" id="class____Injector_html_a3463b30b920b35418ded0984fe8ae387"><div class="ttname"><a href="../../de/d11/class____Injector.html#a3463b30b920b35418ded0984fe8ae387">__Injector::flux</a></div><div class="ttdeci">double flux</div><div class="ttdoc">束流,粒子数/立方米/s </div><div class="ttdef"><b>Definition:</b> injector.h:30</div></div>
<div class="ttc" id="class____Injector_html_a92a9bdb86b5d437c638e06508d8c9fa6"><div class="ttname"><a href="../../de/d11/class____Injector.html#a92a9bdb86b5d437c638e06508d8c9fa6">__Injector::diameter</a></div><div class="ttdeci">long diameter</div><div class="ttdoc">束流横向所占网格数 </div><div class="ttdef"><b>Definition:</b> injector.h:34</div></div>
<div class="ttc" id="class____Injector_html_aa4848c52c3ab0b96e3ab6ec78f1956e4"><div class="ttname"><a href="../../de/d11/class____Injector.html#aa4848c52c3ab0b96e3ab6ec78f1956e4">__Injector::repetion</a></div><div class="ttdeci">int repetion</div><div class="ttdoc">重复次数,目前美柚用 </div><div class="ttdef"><b>Definition:</b> injector.h:28</div></div>
<div class="ttc" id="class____Simbox_html_a5bcfefa55f12a83d66d28b8e23fbd0f4"><div class="ttname"><a href="../../d9/d37/class____Simbox.html#a5bcfefa55f12a83d66d28b8e23fbd0f4">__Simbox::cellgroup</a></div><div class="ttdeci">__Cellgroup cellgroup</div><div class="ttdoc">当前box中的所有网格的二维数组，通过指标可以直接访问 </div><div class="ttdef"><b>Definition:</b> simbox.h:125</div></div>
<div class="ttc" id="class____Injector_html_a4c049ee41a130898e724da94f449ee2c"><div class="ttname"><a href="../../de/d11/class____Injector.html#a4c049ee41a130898e724da94f449ee2c">__Injector::charge</a></div><div class="ttdeci">double charge</div><div class="ttdoc">粒子电荷 </div><div class="ttdef"><b>Definition:</b> injector.h:38</div></div>
<div class="ttc" id="class____Injector_html_a921bbb4ec1562cfd7ab4e8ac76b619b8"><div class="ttname"><a href="../../de/d11/class____Injector.html#a921bbb4ec1562cfd7ab4e8ac76b619b8">__Injector::trigger</a></div><div class="ttdeci">void trigger(__Simbox &amp;mybox)</div><div class="ttdoc">入射粒子加入到box中 </div><div class="ttdef"><b>Definition:</b> injector.h:65</div></div>
<div class="ttc" id="class____Ptcls_html_a190602549e77f92d18694bfac93774de"><div class="ttname"><a href="../../d9/ddf/class____Ptcls.html#a190602549e77f92d18694bfac93774de">__Ptcls::species</a></div><div class="ttdeci">int species</div><div class="ttdoc">粒子的种类：0电子，1：离子，2：正电子，3：光子 </div><div class="ttdef"><b>Definition:</b> particles.h:62</div></div>
<div class="ttc" id="class____Injector_html_aaf0d94bdf7f6bf59a56f9ad7335ee591"><div class="ttname"><a href="../../de/d11/class____Injector.html#aaf0d94bdf7f6bf59a56f9ad7335ee591">__Injector::velocity</a></div><div class="ttdeci">__Vect3&lt; double &gt; velocity</div><div class="ttdoc">束流速度 </div><div class="ttdef"><b>Definition:</b> injector.h:22</div></div>
<div class="ttc" id="class____Injector_html_a1e2e93fb02efca4f2cb4a0d5afb56c8a"><div class="ttname"><a href="../../de/d11/class____Injector.html#a1e2e93fb02efca4f2cb4a0d5afb56c8a">__Injector::gps</a></div><div class="ttdeci">__Vect2&lt; double &gt; gps</div><div class="ttdoc">GPS of gun. </div><div class="ttdef"><b>Definition:</b> injector.h:20</div></div>
<div class="ttc" id="class____Injector_html_a4b73407b88f8100467ff96223daf0c16"><div class="ttname"><a href="../../de/d11/class____Injector.html#a4b73407b88f8100467ff96223daf0c16">__Injector::species</a></div><div class="ttdeci">int species</div><div class="ttdoc">入射粒子种类 </div><div class="ttdef"><b>Definition:</b> injector.h:16</div></div>
<div class="ttc" id="class____Vect3_html"><div class="ttname"><a href="../../da/d1a/class____Vect3.html">__Vect3&lt; double &gt;</a></div></div>
<div class="ttc" id="class____Injector_html_a766d44b1386fd4f010f0bd43f36f3ad0"><div class="ttname"><a href="../../de/d11/class____Injector.html#a766d44b1386fd4f010f0bd43f36f3ad0">__Injector::energy</a></div><div class="ttdeci">double energy</div><div class="ttdoc">单个粒子能量,j </div><div class="ttdef"><b>Definition:</b> injector.h:36</div></div>
<div class="ttc" id="class____Injector_html"><div class="ttname"><a href="../../de/d11/class____Injector.html">__Injector</a></div><div class="ttdoc">粒子入射枪,可以指定粒子种类,和入射位置,目前尽采用四方形束流,以后会有更多的如高斯型等. </div><div class="ttdef"><b>Definition:</b> injector.h:12</div></div>
<div class="ttc" id="class____Injector_html_a50f2657e4e2d8fe60619f8c7b9f23a8c"><div class="ttname"><a href="../../de/d11/class____Injector.html#a50f2657e4e2d8fe60619f8c7b9f23a8c">__Injector::length</a></div><div class="ttdeci">double length</div><div class="ttdoc">束流横向宽度 </div><div class="ttdef"><b>Definition:</b> injector.h:26</div></div>
<div class="ttc" id="class____Ptcls_html_a4c8ff1d2388163601e00c6685af2859a"><div class="ttname"><a href="../../d9/ddf/class____Ptcls.html#a4c8ff1d2388163601e00c6685af2859a">__Ptcls::mass</a></div><div class="ttdeci">double mass</div><div class="ttdoc">粒子质量，没有乘以权重 </div><div class="ttdef"><b>Definition:</b> particles.h:82</div></div>
<div class="ttc" id="class____Injector_html_a648d24d44961e7a00296d743b155574c"><div class="ttname"><a href="../../de/d11/class____Injector.html#a648d24d44961e7a00296d743b155574c">__Injector::total</a></div><div class="ttdeci">long total</div><div class="ttdoc">入射宏粒子总数 </div><div class="ttdef"><b>Definition:</b> injector.h:42</div></div>
<div class="ttc" id="class____Simbox_html"><div class="ttname"><a href="../../d9/d37/class____Simbox.html">__Simbox</a></div><div class="ttdoc">初始化一个模拟盒子，这个模拟盒子包含cell信息，粒子信息，场信息。粒子种类信息也在这里。 ...</div><div class="ttdef"><b>Definition:</b> simbox.h:51</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Tue Jun 16 2015 22:48:37 for hybridMPIC by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen"/>
</a> 1.8.9.1
</small></address>
</body>
</html>
